use "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Data Files/Wave 1 Weighted.dta"

***Defining Variables***
generate pid3 =.
replace pid3 = 1 if partyid7 < 4
replace pid3 = 2 if partyid7 == 4
replace pid3 = 3 if partyid7 > 4

generate ideo3 =.
replace ideo3 = 1 if ideo < 4
replace ideo3 = 2 if ideo == 4
replace ideo3 = 3 if ideo > 4 & ideo < 8
replace ideo3 = 4 if ideo == 8

replace q8 =. if q8 == 98
generate q8a =.
replace q8a = 0 if q8 > 2
replace q8a = 1 if q8 < 3
replace q8a =. if q8 ==.

generate q8h = 0 if q8 < 77
replace q8h = 1 if q8 == 1

generate q10a2 = 0 if q10 < 77
replace q10a2 = 1 if q10 < 3

generate q11a2 = 0 if q11 < 77
replace q11a2 = 1 if q11 < 3

replace q9 =. if q9 > 12
replace q9 = q9 - 1
replace q10a =. if q10a > 12
replace q10a = q10a - 1
replace q11a =. if q11a > 12
replace q11a = q11a - 1

*********************
*****Table 2.2*****
tab q8h partyid7 [aweight=weight] if dov_assignment_a == 1, column
tab q8h pid3 [aweight=weight] if dov_assignment_a == 1, column
tab q8a partyid7 [aweight=weight] if dov_assignment_a == 1, column
tab q8a pid3 [aweight=weight] if dov_assignment_a == 1, column
mean q9 [pweight=weight] if dov_assignment_a == 1, over(partyid7)
mean q9 [pweight=weight] if dov_assignment_a == 1, over(pid3)

*****Table 2.3*****
tab q8h ideo [aweight=weight] if dov_assignment_a == 1, column
tab q8h ideo3 [aweight=weight] if dov_assignment_a == 1, column
tab q8a ideo [aweight=weight] if dov_assignment_a == 1, column
tab q8a ideo3 [aweight=weight] if dov_assignment_a == 1, column
mean q9 [pweight=weight] if dov_assignment_a == 1, over(ideo)
mean q9 [pweight=weight] if dov_assignment_a == 1, over(ideo3)

*****Table 2.6*****
tab q8a pid3 [aweight=weight] if dov_assignment_a == 1, column
tab q10a2 pid3 [aweight=weight] if dov_assignment_a == 1, column
tab q11a2 pid3 [aweight=weight] if dov_assignment_a == 1, column


*********
clear all

********************
use "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Data Files/GOFO name data.dta"

*****Figure 2.11*****
graph bar correct incorrect dk nho, over(gofo, label(angle(vertical) labsize(small))) bar(1, fcolor(gs5))bar(2, fcolor(gs8)) bar(3, fcolor(gs11)) bar(4, fcolor(gs14)) ytitle(Percentage of Answers) ytitle(, size(medsmall)) yscale(range(0 1)) ylabel(#6) name(party, replace) graphregion(fcolor(white) lcolor(white) lwidth(thin) lalign(outside) ifcolor(none) ilcolor(none)) plotregion(fcolor(white) lcolor(black) lpattern(solid) lalign(outside) ifcolor(none)) stack

*********
clear

********************
use "/Users/jimgolby/Desktop/ZB - Confidence Book/Technical Appendix/Data Files/Wave 2.dta"

***Defining Variables***
generate PID3 =.
replace PID3 = 1 if PARTYID < 4
replace PID3 = 2 if PARTYID == 4
replace PID3 = 3 if PARTYID > 4

replace Q35 =. if Q35 == 98

*****Table 2.7*****
tab Q35 PID3 [aweight=weight2], column
tab Q35 PID3 [aweight=weight2] if P_ASSIGN1 == 1, column



